{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}

<div class="box is-sideless is-fullwidth is-marginless is-bottomless">

  <Hds::PageHeader class="page-header" as |PH|>
    <PH.Breadcrumb>
      <Hds::Breadcrumb data-test-breadcrumbs>
        <Hds::Breadcrumb::Item @text="Secrets engines" @route="vault.cluster.secrets.backends" />
        <Hds::Breadcrumb::Item @text="Enable secrets engine" @route="vault.cluster.secrets.enable" />
        <Hds::Breadcrumb::Item @text={{capitalize @model.type}} @current={{true}} />
      </Hds::Breadcrumb>
    </PH.Breadcrumb>
  </Hds::PageHeader>

  <MessageError @errorMessage={{this.errorMessage}} />

  <form {{on "submit" (perform this.mountBackend)}}>
    <FormFieldGroups
      @model={{@model}}
      @groupName="formFieldGroups"
      @renderGroup="default"
      @modelValidations={{this.modelValidations}}
      @onKeyUp={{this.onKeyUp}}
    />

    <FormFieldGroups @model={{@model}} @renderGroup="Method Options" @groupName="formFieldGroups">
      <:identityTokenKey>
        <SearchSelectWithModal
          @id="key"
          @fallbackComponent="input-search"
          @inputValue={{@model.data.config.identity_token_key}}
          @onChange={{this.handleIdentityTokenKeyChange}}
          @models={{array "oidc/key"}}
          @selectLimit="1"
          @modalFormTemplate="modal-form/oidc-key-template"
          @placeholder="Search for an existing OIDC key, or type a new key name to create it."
          @fallbackComponentPlaceholder="Input a key name"
          @modalSubtext="This key will be created in the OIDC key path."
          data-test-field="config.identity_token_key"
        />
      </:identityTokenKey>
    </FormFieldGroups>

    <div class="field is-grouped box is-fullwidth is-bottomless">
      <div class="control">
        <Hds::Button
          @text="Enable engine"
          @icon={{if this.mountBackend.isRunning "loading"}}
          type="submit"
          data-test-submit
          disabled={{this.mountBackend.isRunning}}
        />
      </div>
      <div class="control">
        <Hds::Button @text="Back" @color="secondary" {{on "click" this.goBack}} data-test-back-button />
      </div>
      {{#if this.invalidFormAlert}}
        <div class="control">
          <AlertInline @type="danger" class="has-top-padding-s" @message={{this.invalidFormAlert}} />
        </div>
      {{/if}}
    </div>
  </form>
</div>